Skip to content

Support _value_ as a fallback for ellipsis Enum members #19352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sterliakov
Copy link
Collaborator

@sterliakov sterliakov commented Jun 27, 2025

Fixes #19334.

This does not affect enums with explicit values different from ellipsis and is limited to enums defined in stub files.

This comment has been minimized.

This comment has been minimized.

@sterliakov sterliakov marked this pull request as ready for review June 28, 2025 12:12

This comment has been minimized.

Copy link
Collaborator

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a couple nitpicks.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jul 7, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good, except for a nit about cyclic import dependencies. This is good to merge as is, since the issue is pretty minor, but it would be nice you can fix it in a follow-up PR.

@@ -17,10 +17,12 @@
from typing import TypeVar, cast

import mypy.plugin # To avoid circular imports.
from mypy.nodes import TypeInfo
from mypy.checker import TypeChecker
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit unfortunate that we have another circular import dependency. What about adding adding a helper method for checking whether we are type checking a stub file to the checker api? (It's okay to do this in a follow-up PR.)

@JukkaL JukkaL merged commit 5d59e43 into python:master Jul 9, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enum types are incorrectly inferred
4 participants